home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / prog_d / isamexpt.zip / WNTISAM1.PAS < prev    next >
Pascal/Delphi Source File  |  1996-01-13  |  13KB  |  433 lines

  1. unit Wntisam1;
  2.  
  3. interface
  4. Uses Classes, Forms, Graphics;
  5.  
  6. Function Erzeuge_BrowserForm(const FormIdent, TblName: string;
  7.                              IniDatNam,IniBrwNam: String;
  8.                              Fnt: TFont;
  9.                              IIDList,KeyList,RecList: TStringList;
  10.                              DBase_Export,DBase_Import: Boolean;
  11.                              Sprache: Integer): TForm;
  12.  
  13. implementation
  14.  
  15. Uses UToolDll, WinTypes, WinProcs, SysUtils,
  16.      ExtCtrls, Buttons, Controls, IsamTabl, IsamNav, IsamBrow,
  17.      Proxies, IStreams, FvcBrows;
  18.  
  19. Function Erzeuge_BrowserForm(const FormIdent, TblName: string;
  20.                              IniDatNam,IniBrwNam: String;
  21.                              Fnt: TFont;
  22.                              IIDList,KeyList,RecList: TStringList;
  23.                              DBase_Export,DBase_Import: Boolean;
  24.                              Sprache: Integer): TForm;
  25. var
  26.   BtnPos         : TPoint;
  27.   EdMethod,Method: TMethod;
  28.   MP,UP,Up1,Up2,Up3: TPanel;
  29.   SP             : TSpeedButton;
  30.   Tbl            : TIsamTable;
  31.   Tm             : TTimer;
  32.   i,k            : Integer;
  33.   ND             : TIsamNavigator;
  34.   Grd            : TIsamBrowser;
  35.   Hdr            : THeader;
  36.   x              : Integer;
  37.   RStr,NStr,xStr : String;
  38.   Liste1,Liste2,Liste3: TStringList;
  39. begin
  40.   Result := TProxyForm.CreateAs('T' + FormIdent);
  41.   with Result do begin
  42.     BorderStyle := bsDialog;
  43.     AutoScroll  := True;
  44.     Left  := 92;
  45.     Top   := 97;
  46.     Width := 562;
  47.     Height:= 352; 
  48.     Position := poScreenCenter;
  49.     Name := FormIdent;
  50.     Caption := 'Browser';
  51.     Method.Code := TProxyForm(Result).CreateMethod('FormCreate');
  52.     Method.Data := Result;
  53.     OnCreate    := TNotifyEvent(Method);
  54.     Method.Code := TProxyForm(Result).CreateMethod('FormDestroy');
  55.     Method.Data := Result;
  56.     OnDestroy   := TNotifyEvent(Method);
  57.     Method.Code := TProxyForm(Result).CreateMethod('FormShow');
  58.     Method.Data := Result;
  59.     OnShow      := TNotifyEvent(Method);
  60.     with Font do begin
  61.       Color := clBlack;
  62.       Height:= -11;
  63.       Name := 'Arial';
  64.       Size := 8;
  65.       Style:= [fsBold];
  66.     end;
  67.  
  68.     MP:= TPanel.Create(Result);
  69.     with MP do begin
  70.       Parent := Result;
  71.       Name   := 'Panel1';
  72.       Left   := 0;
  73.       Top    := 0;
  74.       Width  := 554;
  75.       Height := 41;
  76.       Align  := alTop;
  77.       ParentShowHint:= False;
  78.       ShowHint := True;
  79.       TabOrder := 1;
  80.       Caption:= '';
  81.     end;
  82.  
  83.     Tm:= TTimer.Create(Result);
  84.     With Tm do begin
  85.       Interval:= 1000;
  86.       Name:= FormIdent+'Timer';
  87.       Method.Code := TProxyForm(Result).CreateMethod(FormIdent+'TimerTimer');
  88.       Method.Data := Result;
  89.       Tm.OnTimer := TNotifyEvent(Method);
  90.     end;
  91.  
  92.     Hdr:= THeader.Create(Result);
  93.     with Hdr do begin
  94.       Parent:= Result;
  95.       Name:= 'HEADER1';
  96.       Left:= 0;
  97.       Top:= 41;
  98.       Height:= 25;
  99.       Width:= 554;
  100.       Method.Code := TProxyForm(Result).CreateMethod('Header1Sized');
  101.       Method.Data := Result;
  102.       OnSized:= TSectionEvent(Method);
  103.     end;
  104.  
  105.     Tbl:= TIsamTable.Create(Result);
  106.     with Tbl do begin
  107.       Name:= FormIdent+'TABLE';
  108.       TableName:= TblName;
  109.       BrowserName:= 'IsamBrowser1';
  110.       HeaderName:= 'HEADER1';
  111.       Ansiconvert:= True;
  112.       Liste1:= TStringList.Create;
  113.       {IIDProc.Clear;}
  114.       x:= 0;
  115.       While x < IIDList.Count do begin
  116.         Liste1.Add(IIDList[x]);
  117.         Inc(x);
  118.       end;
  119.       MaxKeys:= x;
  120.       IIDProc:= Liste1;
  121.       Liste1.Free;
  122.       Liste2:= TStringList.Create;
  123.       {IsamRecord.Clear;}
  124.       RecordName:= '';
  125.       x:= 0;
  126.       While x < RecList.Count do begin
  127.         Liste2.Add(RecList[x]);
  128.         RStr:= Uppercase(RecList[x]);
  129.         Strip(RStr);
  130.         if Pos('=RECORD',RStr) > 0 then RecordName:= Copy(RStr,1,Pos('=RECORD',RStr)-1);
  131.         inc(x);
  132.       end;
  133.       IsamRecord:= Liste2;
  134.       Liste2.Free;
  135.       {IsamKeyProc.Clear;}
  136.       Liste3:= TStringList.Create;
  137.       K:= 0;
  138.       if KeyList.Count > 0 then begin
  139.         Liste3.Add('Function '+RecordName+'KeyProc(Var Daten; KeyNr:Word): IsamKeyStr;');
  140.         Liste3.Add('var s : String;');
  141.         Liste3.Add('begin');
  142.         Liste3.Add('  s:= '+Chr(39)+Chr(39)+';');
  143.         Liste3.Add('  With '+RecordName+'(Daten) do begin');
  144.         Liste3.Add('    case KeyNr of');
  145.         For x:= 0 to KeyList.Count-1 do begin
  146.           NStr:= KeyList[x];
  147.           NStr:= UpperCase(NStr);
  148.           if Pos(';',NStr) = 0 then KeyList[x]:= KeyList[x]+';';
  149.           Strip(NStr);
  150.           if (Pos('KEYBEGIN',NStr) = 0) and (Pos('KEYEND',NStr) = 0) then begin
  151.             inc(K);
  152.             Str(k,xStr);
  153.             Liste3.Add(xStr+': '+KeyList[x]);
  154.           end;
  155.         end;
  156.         Liste3.Add('    end;');
  157.         Liste3.Add('  end;');
  158.         Liste3.Add('  '+RecordName+'KEYPROC:= S;');
  159.         Liste3.Add('end;');
  160.       end;
  161.       IsamKeyProc:= Liste3;
  162.       Liste3.Free;
  163.       MyUnitName:= FormIdent;
  164.     end;
  165.  
  166.     Grd:= TIsamBrowser.Create(Result);
  167.     with Grd do begin
  168.       Parent          := Result;
  169.       Name            := 'IsamBrowser1';
  170.       Left            := 0;
  171.       Top             := 66;
  172.       Width           := 554;
  173.       Height          := 232;
  174.       Align           := alNone;
  175.       Color           := clSilver;
  176.       BrowserHeader   := Hdr;
  177.       Table           := Tbl;
  178.       Font.Color      := Fnt.Color;
  179.       Font.Height     := Fnt.Height;
  180.       Font.Name       := Fnt.Name;
  181.       Font.Style      := Fnt.Style;
  182.       ParentFont      := False;
  183.       TabOrder        := 2;
  184.       EdMethod.Code := TProxyForm(Result).CreateMethod('EditBttnClick');
  185.       EdMethod.Data := Result;
  186.       Grd.OnDblClick  := TNotifyEvent(EdMethod);
  187.       Method.Code:= TProxyForm(Result).CreateMethod('IsamBrowser1BuildRow');
  188.       Method.Data:= Result;
  189.       Grd.OnBuildRow:= TBuildRowEvent(Method);
  190.     end;
  191.  
  192.     ND:= TIsamNavigator.Create(Result);
  193.     with ND do begin
  194.       Parent:= MP;
  195.       Browser:= Grd;
  196.       Name:= 'IsamNavigator1';
  197.       ConfirmDelete:= False;
  198.       Left:= 8;
  199.       Top:= 8;
  200.       VisibleButtons:= [nbFirst,nbPrior,nbNext,nbLast];
  201.       Width:= 100;
  202.     end;
  203.  
  204.     Sp:= TSpeedButton.Create(Result);
  205.     with SP do begin
  206.       Parent:= MP;
  207.       Left:= 128;
  208.       Top := 8;
  209.       Width := 25;
  210.       Height := 25;
  211.       if Sprache = 1 then Hint:= 'New record'
  212.       else Hint := 'Neuer Datensatz';
  213.       Name := 'NeuBttn';
  214.       Glyph.Handle:= LoadBitmap(HInstance,'IS_NEU');
  215.       Method.Code := TProxyForm(Result).CreateMethod('NeuBttnClick');
  216.       Method.Data := Result;
  217.       Sp.OnClick := TNotifyEvent(Method);
  218.     end;
  219.  
  220.     Sp:= TSpeedButton.Create(Result);
  221.     with SP do begin
  222.       Parent:= MP;
  223.       Left:= 156;
  224.       Top := 8;
  225.       Width := 25;
  226.       Height := 25;
  227.       if Sprache = 1 then Hint:= 'Edit record'
  228.       else Hint := 'Datensatz bearbeiten';
  229.       Name := 'EditBttn';
  230.       Glyph.Handle:= LoadBitmap(HInstance,'IS_AENDERN');
  231.       Sp.OnClick := TNotifyEvent(EdMethod);
  232.     end;
  233.  
  234.     Sp:= TSpeedButton.Create(Result);
  235.     with SP do begin
  236.       Parent:= MP;
  237.       Left:= 184;
  238.       Top := 8;
  239.       Width := 25;
  240.       Height := 25;
  241.       if Sprache = 1 then Hint:= 'Search'
  242.       else Hint := 'Suchen';
  243.       Name := 'SuchBttn';
  244.       Glyph.Handle:= LoadBitmap(HInstance,'IS_SUCH');
  245.       Method.Code := TProxyForm(Result).CreateMethod('SuchBttnClick');
  246.       Method.Data := Result;
  247.       Sp.OnClick := TNotifyEvent(Method);
  248.     end;
  249.  
  250.     Sp:= TSpeedButton.Create(Result);
  251.     with SP do begin
  252.       Parent:= MP;
  253.       Left:= 212;
  254.       Top := 8;
  255.       Width := 25;
  256.       Height := 25;
  257.       if Sprache = 1 then Hint:= 'sort-order'
  258.       else Hint := 'Sortierordnung';
  259.       Name := 'KeyBttn';
  260.       Glyph.Handle:= LoadBitmap(HInstance,'IS_KEY');
  261.       Method.Code := TProxyForm(Result).CreateMethod('KeyBttnClick');
  262.       Method.Data := Result;
  263.       Sp.OnClick := TNotifyEvent(Method);
  264.     end;
  265.  
  266.     Sp:= TSpeedButton.Create(Result);
  267.     with SP do begin
  268.       Parent:= MP;
  269.       Left:= 240;
  270.       Top := 8;
  271.       Width := 25;
  272.       Height := 25;
  273.       if Sprache = 1 then Hint:= 'Delete'
  274.       else Hint := 'L÷schen';
  275.       Name := 'LoeschBttn';
  276.       Glyph.Handle:= LoadBitmap(HInstance,'IS_LOESCHEN');
  277.       Method.Code := TProxyForm(Result).CreateMethod('LoeschBttnClick');
  278.       Method.Data := Result;
  279.       Sp.OnClick := TNotifyEvent(Method);
  280.     end;
  281.  
  282.     Sp:= TSpeedButton.Create(Result);
  283.     with SP do begin
  284.       Parent:= MP;
  285.       Left:= 268;
  286.       Top := 8;
  287.       Width := 25;
  288.       Height := 25;
  289.       if Sprache = 1 then Hint:= 'Reorganize table'
  290.       else Hint := 'Tabelle reorganisieren';
  291.       Name := 'ReorgBttn';
  292.       Glyph.Handle:= LoadBitmap(HInstance,'IS_REORG');
  293.       Method.Code := TProxyForm(Result).CreateMethod('ReorgBttnClick');
  294.       Method.Data := Result;
  295.       Sp.OnClick := TNotifyEvent(Method);
  296.     end;
  297.  
  298.     Sp:= TSpeedButton.Create(Result);
  299.     with SP do begin
  300.       Parent:= MP;
  301.       Left:= 296;
  302.       Top := 8;
  303.       Width := 25;
  304.       Height := 25;
  305.       if Sprache = 1 then Hint:= 'Setup browser'
  306.       else Hint := 'Browser einstellen';
  307.       Name := 'BrwBttn';
  308.       Glyph.Handle:= LoadBitmap(HInstance,'IS_BRWSETUP');
  309.       Method.Code := TProxyForm(Result).CreateMethod('BrwBttnClick');
  310.       Method.Data := Result;
  311.       Sp.OnClick := TNotifyEvent(Method);
  312.     end;
  313.  
  314.     if DBase_Export then begin
  315.       Sp:= TSpeedButton.Create(Result);
  316.       with SP do begin
  317.         Parent:= MP;
  318.         Left:= 324;
  319.         Top := 8;
  320.         Width := 25;
  321.         Height := 25;
  322.         Hint := 'DBase-Export';
  323.         Name := 'DBExpBttn';
  324.         Glyph.Handle:= LoadBitmap(HInstance,'IS_DBEXPORT');
  325.         NumGlyphs:= 2;
  326.         Method.Code := TProxyForm(Result).CreateMethod('DBExpBttnClick');
  327.         Method.Data := Result;
  328.         Sp.OnClick := TNotifyEvent(Method);
  329.       end;
  330.     end;
  331.  
  332.     if DBASE_Import then begin
  333.       Sp:= TSpeedButton.Create(Result);
  334.       with SP do begin
  335.         Parent:= MP;
  336.         if DBase_Export then Left:= 352 else Left:= 324;
  337.         Top := 8;
  338.         Width := 25;
  339.         Height := 25;
  340.         Hint := 'DBase-Import';
  341.         Name := 'DBImpBttn';
  342.         Glyph.Handle:= LoadBitmap(HInstance,'IS_DBIMPORT');
  343.         NumGlyphs:= 2;
  344.         Method.Code := TProxyForm(Result).CreateMethod('DBImpBttnClick');
  345.         Method.Data := Result;
  346.         Sp.OnClick := TNotifyEvent(Method);
  347.       end;
  348.     end;
  349.     Sp:= TSpeedButton.Create(Result);
  350.     with SP do begin
  351.       Parent:= MP;
  352.       Left:= 520;
  353.       Top := 8;
  354.       Width := 25;
  355.       Height := 25;
  356.       if Sprache = 1 then Hint:= 'End'
  357.       else Hint := 'Ende';
  358.       Name := 'ExitBttn';
  359.       Glyph.Handle:= LoadBitmap(HInstance,'IS_ENDE');
  360.       Method.Code := TProxyForm(Result).CreateMethod('ExitBttnClick');
  361.       Method.Data := Result;
  362.       Sp.OnClick := TNotifyEvent(Method);
  363.     end;
  364.  
  365.     UP:= TPanel.Create(Result);
  366.     with UP do begin
  367.       Parent := Result;
  368.       Name := 'Panel2';
  369.       Align := alBottom;
  370.       BevelInner:= bvLowered;
  371.       Height:= 27;
  372.       ShowHint:= False;
  373.       Caption:= '';
  374.     end;
  375.  
  376.     UP1:= TPanel.Create(Result);
  377.     With UP1 do begin
  378.       Parent:= UP;
  379.       Left  := 308;
  380.       Top   := 2;
  381.       Width := 108;
  382.       Height:= 23;
  383.       Align := alRight;
  384.       BevelOuter := bvLowered;
  385.       Font.Color := clBlack;
  386.       Font.Height := -11;
  387.       Font.Name := 'Arial';
  388.       Font.Style := [];
  389.       Name:= 'ZeitPanel';
  390.       Caption:= '';
  391.     end;
  392.  
  393.     UP2:= TPanel.Create(Result);
  394.     With UP2 do begin
  395.       Parent:= UP;
  396.       Left  := 2;
  397.       Top   := 2;
  398.       Width := 127;
  399.       Height:= 23;
  400.       Align := alLeft;
  401.       Alignment:= taLeftJustify;
  402.       BevelOuter := bvLowered;
  403.       Font.Color := clBlack;
  404.       Font.Height := -11;
  405.       Font.Name := 'Arial';
  406.       Font.Style := [];
  407.       Name:= 'KeyPanel';
  408.       Caption:= 'Key';
  409.     end;
  410.  
  411.     UP3:= TPanel.Create(Result);
  412.     with UP3 do begin
  413.       Parent:= UP;
  414.       Left  := 2;
  415.       Top   := 2;
  416.       Width := 186;
  417.       Height:= 23;
  418.       Align := alClient;
  419.       ShowHint:= True;
  420.       BevelInner := bvLowered;
  421.       BevelOuter := bvNone;
  422.       Font.Color := clBlack;
  423.       Font.Height := -11;
  424.       Font.Name   := 'Arial';
  425.       Font.Style  := [];
  426.       Name:= 'Statusbar';
  427.       Caption:= '';
  428.     end;
  429.   end;
  430. end;
  431.  
  432. end.
  433.